fix(mcp): filter private comments for portal details#48
Open
BunsDev wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes a regression in the MCP get_details tool where portal (non-team) users could receive private/team-only comments by ensuring the includePrivate option is correctly passed to getCommentsWithReplies.
Changes:
- Compute
includeTeamOnlyFieldsfrom the caller’s role and pass it asincludePrivateintogetCommentsWithRepliesfor post details. - Add unit assertions to verify
includePrivateisfalsefor OAuth portal users andtruefor team members.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/web/src/lib/server/mcp/tools.ts | Ensures comment fetching honors team membership by wiring includePrivate into the query call. |
| apps/web/src/lib/server/mcp/tests/handler.test.ts | Adds tests asserting the correct includePrivate flag is passed for portal vs team contexts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+910
to
+918
| vi.mocked(getDeveloperConfig) | ||
| .mockResolvedValueOnce({ | ||
| mcpEnabled: true, | ||
| mcpPortalAccessEnabled: true, | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| mcpEnabled: true, | ||
| mcpPortalAccessEnabled: true, | ||
| }) |
Comment on lines
+942
to
+945
| expect(response.status).toBe(200) | ||
| expect(vi.mocked(getCommentsWithReplies)).toHaveBeenCalledWith('post_test', undefined, { | ||
| includePrivate: false, | ||
| }) |
Comment on lines
+961
to
+964
| expect(response.status).toBe(200) | ||
| expect(vi.mocked(getCommentsWithReplies)).toHaveBeenCalledWith('post_test', undefined, { | ||
| includePrivate: true, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
getCommentsWithReplieswas called without theincludePrivateoption.Description
getCommentsWithRepliesby computingincludeTeamOnlyFields = isTeamMember(auth.role)and callinggetCommentsWithReplies(postId, undefined, { includePrivate: includeTeamOnlyFields })inapps/web/src/lib/server/mcp/tools.ts.apps/web/src/lib/server/mcp/__tests__/handler.test.tsthat verifygetCommentsWithRepliesis invoked withincludePrivate: falsefor an OAuth portal user andincludePrivate: truefor a team member.Testing
git diff --checkwhich reported no whitespace errors and the diff is as expected.bun test apps/web/src/lib/server/mcp/__tests__/handler.test.tsbut the run failed withTypeError: vi.mock is not a functionbecause the environment invoked Bun's test runner while the suite uses Vitest APIs.bun install --frozen-lockfileto install deps for full test runs but this was blocked by npm registry403errors, so the added tests could not be fully executed in this environment.Codex Task